package com.hzhq.contract.status;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

/**
 * @author hzhq
 * @create 2021/4/11 3:59 下午
 * @email hzhq1255@163.com
 */
@Component
public class DefaultValue {




    public static final Integer NOT_DELETED = 0;
    public static final String NOT_DELETED_STRING = "0";
    public static final Integer DELETED = 1;
    public static final String DELETED_STRING = "1";
    public static final Integer IS_ADMIN = 1;
    public static final Integer NOT_ADMIN = 0;
    public static final Integer REJECT_PASSED = -1;
    public static final Integer NOT_PASSED = 0;
    public static final Integer PASSED_REVIEW = 1;
    public static final Integer PASSED_ADMIN = 2;
    public static final Integer SYSTEM_ADMIN = 0;
    public static final Integer DEPART_ADMIN = 1;
    public static final Integer COMPLETED = 1;
    public static final Integer NOT_COMPLETED = 0;

    public static final Map<Integer,String> ROLE_TYPE_MAP = new HashMap<>();
    static {
        ROLE_TYPE_MAP.put(0,"管理员");
        ROLE_TYPE_MAP.put(1,"审批人员");
        ROLE_TYPE_MAP.put(2,"录入人员");
    }

    public static final Map<Integer,String> ADMIN_TYPE_MAP = new HashMap<>();
    static {
        ADMIN_TYPE_MAP.put(0,"系统管理员");
        ADMIN_TYPE_MAP.put(1,"部门管理员");
    }


    public static final Map<Integer,String> PASSED_STATUS_MAP = new HashMap<>();
    static {
        PASSED_STATUS_MAP.put(-1,"拒绝");
        PASSED_STATUS_MAP.put(0,"未通过");
        PASSED_STATUS_MAP.put(1,"已通过");
    }

    public static Integer getKey(HashMap<Integer,String> map, String value){
        Integer key = null;
        for (Map.Entry<Integer,String> entry: map.entrySet()){
            if (value.equals(entry.getValue())){
                key = entry.getKey();
            }
        }
        return key;
    }

    public static Integer getRoleTypeCode(String type){
        Integer typeCode = null;
        for (Map.Entry<Integer,String> entry: ROLE_TYPE_MAP.entrySet()){
            if (type.equals(entry.getValue())){
                typeCode = entry.getKey();
            }
        }
        return typeCode;
    }

    public static Integer getAdminTypeCode(String type){
        Integer typeCode = null;
        for (Map.Entry<Integer,String> entry: ADMIN_TYPE_MAP.entrySet()){
            if (type.equals(entry.getValue())){
                typeCode = entry.getKey();
            }
        }
        return typeCode;
    }

    public static void main(String[] args) {
        System.out.println(getAdminTypeCode("系统管理员"));
    }
}
